<template>
    <div class="login-container">
        <div class="login-background"></div>
        <div class="login-content">
            <div class="login-card">
                <h2 class="login-title">系统登录</h2>
                <div class="login-subtitle">欢迎来到未来世界</div>

                <el-form :model="form" class="login-form">
                    <el-form-item>
                        <el-input v-model="form.name" placeholder="请输入账号" class="sci-fi-input">
                            <template #prefix>
                                <el-icon>
                                    <user />
                                </el-icon>
                            </template>
                        </el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-input v-model="form.password" type="password" placeholder="请输入密码" show-password
                            class="sci-fi-input">
                            <template #prefix>
                                <el-icon>
                                    <lock />
                                </el-icon>
                            </template>
                        </el-input>
                    </el-form-item>


                    <el-form-item>
                        <el-button type="primary"class='login-btn'  @click="onSubmit">登录</el-button>
                        <el-button type="primary" class='cancel-btn'>取消</el-button>
                    </el-form-item>
                </el-form>

                <div class="login-footer">
                    <div class="neon-line"></div>
                    <div class="footer-links">
                        <a href="#">忘记密码</a>
                        <a href="#">注册账号</a>
                        <a href="#">帮助中心</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>


<script lang="ts" setup>
import { addDynamicRoutes } from '@/router'
import { reactive } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
import axios from 'axios'
const form = reactive({
    name: 'admin',
    password: 123456
})
const onSubmit = async () => {
    const result = await axios.get('http://localhost:3333/login', {
        params: form
    });
    addDynamicRoutes(result.data.route)
    localStorage.setItem('menuList', JSON.stringify(result.data.route))
    localStorage.setItem('token', JSON.stringify(result.data.token))
    router.push('/');

};
</script>
<style scoped lang="less">
.login-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Arial', sans-serif;
}

.login-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* 替换为你自己的背景图片 */
    background-image: url('../assets/bg.jpg');
    background-size: cover;
    background-position: center;
    filter: brightness(0.4);
    z-index: 0;
}

.login-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1200px;
    display: flex;
    justify-content: flex-end;
    padding: 2rem;
}

.login-card {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 40px;
    width: 400px;
    box-shadow: 0 0 30px rgba(0, 150, 255, 0.3);
    border: 1px solid rgba(0, 180, 255, 0.2);
    animation: glow 3s infinite alternate;
}

@keyframes glow {
    from {
        box-shadow: 0 0 20px rgba(0, 150, 255, 0.3);
    }

    to {
        box-shadow: 0 0 30px rgba(0, 180, 255, 0.6);
    }
}

.login-title {
    color: #fff;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    text-align: center;
    margin-bottom: 30px;
    letter-spacing: 1px;
}

.login-form {
    margin-top: 20px;
}

.sci-fi-input {
    :deep(.el-input__wrapper) {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(0, 180, 255, 0.3);
        box-shadow: none;
        border-radius: 6px;
        transition: all 0.3s;

        &:hover {
            border-color: rgba(0, 180, 255, 0.6);
        }

        &.is-focus {
            border-color: rgba(0, 180, 255, 0.8);
            box-shadow: 0 0 10px rgba(0, 180, 255, 0.3);
        }
    }

    :deep(.el-input__inner) {
        color: #fff;

        &::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }
    }

    :deep(.el-icon) {
        color: rgba(0, 180, 255, 0.8);
        font-size: 18px;
    }
}

.login-btn,
.cancel-btn {
    width: 100%;
    height: 48px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 1px;
    transition: all 0.3s;
    margin-top: 10px;

    &:hover {
        transform: translateY(-2px);
    }

    &:active {
        transform: translateY(0);
    }
}

.login-btn {
    background: linear-gradient(90deg, #0066ff, #00aaff);
    border: none;
    box-shadow: 0 4px 10px rgba(0, 150, 255, 0.3);

    &:hover {
        box-shadow: 0 5px 15px rgba(0, 150, 255, 0.4);
    }
}

.cancel-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;

    &:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(0, 180, 255, 0.6);
    }
}

:deep(.el-form-item__content) {
  .el-button + .el-button {
    margin-left: 0 !important; /* 强制取消默认间距 */
  }
}


.login-footer {
    margin-top: 30px;
}

.neon-line {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 180, 255, 0.6), transparent);
    margin-bottom: 20px;
}

.footer-links {
    display: flex;
    justify-content: space-between;

    a {
        color: rgba(255, 255, 255, 0.6);
        font-size: 12px;
        text-decoration: none;
        transition: color 0.3s;

        &:hover {
            color: rgba(0, 180, 255, 0.8);
        }
    }
}
</style>